/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.financing.entity.finserviceorder;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.jeesite.common.collect.ListUtils;
import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.JoinTable;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;
import com.jeesite.modules.base.entity.customer.Customer;
import com.jeesite.modules.base.entity.supplier.Supplier;
import com.jeesite.modules.base.entity.warehouse.Twarehouse;
import com.jeesite.modules.sys.entity.Company;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;

/**
 * 融资服务订单Entity
 *
 * @author YY
 * @version 2021-03-16
 */
@Table(name = "t_financing_service_order", alias = "a", columns = {
        @Column(name = "financing_service_order_id", attrName = "financingServiceOrderId", label = "融资服务订单ID", isPK = true),
        @Column(name = "financing_service_order_code", attrName = "financingServiceOrderCode", label = "编号", queryType = QueryType.LIKE),
        @Column(name = "customer_id", attrName = "customerId", label = "客户"),
        @Column(name = "frame_number", attrName = "frameNumber", label = "车架号"),
//        @Column(name = "company_id", attrName = "company.companyCode", label = "代理公司"),
        @Column(name = "company_id", attrName = "companyId", label = "代理公司"),
        @Column(name = "car_total_amount", attrName = "carTotalAmount", label = "车款总金额", comment = "车款总金额（RMB）"),
        @Column(name = "area", attrName = "area", label = "版型"),
        @Column(name = "model", attrName = "model", label = "车型"),
        @Column(name = "brand", attrName = "brand", label = "品牌"),
        @Column(name = "remarks", attrName = "remarks", label = "备注信息", isQuery = false),
        @Column(name = "create_by", attrName = "createBy", label = "创建者", isUpdate = false),
        @Column(name = "create_date", attrName = "createDate", label = "创建时间", isUpdate = false),
        @Column(name = "update_by", attrName = "updateBy", label = "更新者", isQuery = false),
        @Column(name = "update_date", attrName = "updateDate", label = "更新时间", isQuery = false),
        @Column(name = "investor_id", attrName = "investorId", label = "国内资方"),
        @Column(name = "calculation_method", attrName = "calculationMethod", label = "计息方式"),
        @Column(name = "financing_location", attrName = "financingLocation", label = "融资地点"),
        @Column(name = "financing_method", attrName = "financingMethod", label = "融资方式"),
        @Column(name = "minimum_day", attrName = "minimumDay", label = "最少天数"),
        @Column(name = "investor_repayment_date", attrName = "investorRepaymentDate", label = "还款日期"),
        @Column(name = "investor_days", attrName = "investorDays", label = "发生天数"),
        @Column(name = "investor_total_interest", attrName = "investorTotalInterest", label = "利息合计"),
        @Column(name = "investor_total_principal_interest", attrName = "investorTotalPrincipalInterest", label = "本息合计"),
        @Column(name = "customer_repayment_date", attrName = "customerRepaymentDate", label = "还款日期"),
        @Column(name = "customer_days", attrName = "customerDays", label = "发生天数"),
        @Column(name = "customer_total_interest", attrName = "customerTotalInterest", label = "客户利息合计"),
        @Column(name = "customer_total_principal_interest", attrName = "customerTotalPrincipalInterest", label = "客户本息合计"),
        @Column(name = "record_status", attrName = "recordStatus", label = "国内融资方案"),
        @Column(name = "groupname", attrName = "groupName", label = "国内融资方案"),
        @Column(name = "supplier_start_date", attrName = "supplierStartDate", label = "资方开始时间"),
        @Column(name = "customer_start_date", attrName = "customerStartDate", label = "客户开始时间"),
}, joinTable = {
        @JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = Customer.class, attrName = "customer", alias = "b",
                on = "b.customer_id = a.customer_id", columns = {
                @Column(name = "customer_id", label = "客户编号", isPK = true),
                @Column(name = "customer_name", label = "客户名称"),
        }),
        @JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = Supplier.class, attrName = "supplier", alias = "c",
                on = "c.supplier_id = a.investor_id", columns = {
                @Column(name = "supplier_id", label = "供应商编号", isPK = true),
                @Column(name = "supplier_name", label = "供应商名称"),
        }),
        @JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = Company.class, attrName = "company", alias = "d",
                on = "d.company_code=a.company_id", columns = {
                @Column(name = "company_code", label = "公司编码", isPK = true),
                @Column(name = "company_name", label = "公司名称"),
        }),
        @JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = Twarehouse.class, attrName = "warehouse", alias = "e",
                on = "e.warehouse_id=a.financing_location", columns = {
                @Column(name = "warehouse_id", label = "仓库编号", isPK = true),
                @Column(name = "warehouse_name", label = "仓库名称"),
        }),
},
        orderBy = "a.update_date DESC"
)
public class FinServiceOrder extends DataEntity < FinServiceOrder > {

    private static final long serialVersionUID = 1L;
    private String financingServiceOrderId;        // 融资服务订单ID
    private String financingServiceOrderCode;        // 编号
    private String customerId;        // 客户
    private Customer customer;        // 客户
    private String frameNumber;        // 车架号
    private String companyId;        // 代理公司
    private Company company;
    private Double carTotalAmount;        // 车款总金额（RMB）
    private String area;        // 版型
    private String model;        // 车型
    private String brand;        // 品牌
    private String investorId;        // 国内资方
    private Supplier supplier;        // 国内资方
    private String calculationMethod;        // 计息方式
    private String financingLocation;        // 融资地点
    private Twarehouse warehouse;        // 融资地点
    private String financingMethod;        // 融资方式
    private Long minimumDay;        // 最少天数
    private Date investorRepaymentDate;        // 还款日期
    private Long investorDays;        // 发生天数
    private Double investorTotalInterest;        // 利息合计
    private Double investorTotalPrincipalInterest;        // 本息合计
    private Date customerRepaymentDate;        // 还款日期
    private Long customerDays;        // 发生天数
    private Double customerTotalInterest;        // 客户利息合计
    private Double customerTotalPrincipalInterest;        // 客户本息合计
    private Double money;//预收金额（传递数据用的参数）
    private String erpRecordType;//单据类型（传递数据用的参数）
    private String gridRowId;        // 表格行id
    private Date supplierStartDate;		// 资方开始日期
    private Date customerStartDate;		// 资方开始日期
    private String recordStatus;
    private String groupName;  // 国内融资方案
    private List < TfinancingServiceOrderDetail > tfinancingServiceOrderDetailList = ListUtils.newArrayList();
    private List < TfinancingServiceOrderDetail > tfinancingServiceOrderDetailList1 = ListUtils.newArrayList();    //资方子表列表
    private List < TfinancingServiceOrderDetail > tfinancingServiceOrderDetailList2 = ListUtils.newArrayList();    //客户子表列表
    private List < FinancialRecords > financialRecordsList = ListUtils.newArrayList();

    public String getGridRowId() {
        return gridRowId;
    }

    public void setGridRowId(String gridRowId) {
        this.gridRowId = gridRowId;
    }

    public List < FinancialRecords > getFinancialRecordsList() {
        return financialRecordsList;
    }

    public void setFinancialRecordsList(List < FinancialRecords > financialRecordsList) {
        this.financialRecordsList = financialRecordsList;
    }

    public String getErpRecordType() {
        return erpRecordType;
    }

    public void setErpRecordType(String erpRecordType) {
        this.erpRecordType = erpRecordType;
    }

    public Double getMoney() {
        return money;
    }

    public void setMoney(Double money) {
        this.money = money;
    }

    public Customer getCustomer() {
        return customer;
    }

    public List < TfinancingServiceOrderDetail > getTfinancingServiceOrderDetailList() {
        return tfinancingServiceOrderDetailList;
    }

    public void setTfinancingServiceOrderDetailList(List < TfinancingServiceOrderDetail > tfinancingServiceOrderDetailList) {
        this.tfinancingServiceOrderDetailList = tfinancingServiceOrderDetailList;
    }

    public void setCustomer(Customer customer) {
        this.customer = customer;
    }

    public FinServiceOrder() {
        this(null);
    }

    public FinServiceOrder(String id) {
        super(id);
    }

    public String getFinancingServiceOrderId() {
        return financingServiceOrderId;
    }

    public void setFinancingServiceOrderId(String financingServiceOrderId) {
        this.financingServiceOrderId = financingServiceOrderId;
    }

    @Length(min = 0, max = 100, message = "编号长度不能超过 100 个字符")
    public String getFinancingServiceOrderCode() {
        return financingServiceOrderCode;
    }

    public void setFinancingServiceOrderCode(String financingServiceOrderCode) {
        this.financingServiceOrderCode = financingServiceOrderCode;
    }

    @Length(min = 0, max = 64, message = "客户长度不能超过 64 个字符")
    public String getCustomerId() {
        return customerId;
    }

    public void setCustomerId(String customerId) {
        this.customerId = customerId;
    }

    @NotBlank(message = "车架号不能为空")
    @Length(min = 0, max = 100, message = "车架号长度不能超过 100 个字符")
    public String getFrameNumber() {
        return frameNumber;
    }

    public void setFrameNumber(String frameNumber) {
        this.frameNumber = frameNumber;
    }

    @Length(min = 0, max = 64, message = "代理公司长度不能超过 64 个字符")
    public String getCompanyId() {
        return companyId;
    }

    public void setCompanyId(String companyId) {
        this.companyId = companyId;
    }

    @NotNull(message = "车款总金额不能为空")
    public Double getCarTotalAmount() {
        return carTotalAmount;
    }

    public void setCarTotalAmount(Double carTotalAmount) {
        this.carTotalAmount = carTotalAmount;
    }

    @Length(min = 0, max = 64, message = "版型长度不能超过 64 个字符")
    public String getArea() {
        return area;
    }

    public void setArea(String area) {
        this.area = area;
    }

    @Length(min = 0, max = 100, message = "车型长度不能超过 100 个字符")
    public String getModel() {
        return model;
    }

    public void setModel(String model) {
        this.model = model;
    }

    @Length(min = 0, max = 2, message = "品牌长度不能超过 2 个字符")
    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    @NotBlank(message = "国内资方不能为空")
    @Length(min = 0, max = 64, message = "国内资方长度不能超过 64 个字符")
    public String getInvestorId() {
        return investorId;
    }

    public void setInvestorId(String investorId) {
        this.investorId = investorId;
    }

    @NotBlank(message = "计息方式不能为空")
    @Length(min = 0, max = 2, message = "计息方式长度不能超过 2 个字符")
    public String getCalculationMethod() {
        return calculationMethod;
    }

    public void setCalculationMethod(String calculationMethod) {
        this.calculationMethod = calculationMethod;
    }

    @NotBlank(message = "融资地点不能为空")
    @Length(min = 0, max = 64, message = "融资地点长度不能超过 64 个字符")
    public String getFinancingLocation() {
        return financingLocation;
    }

    public void setFinancingLocation(String financingLocation) {
        this.financingLocation = financingLocation;
    }

    @NotBlank(message = "融资方式不能为空")
    @Length(min = 0, max = 2, message = "融资方式长度不能超过 2 个字符")
    public String getFinancingMethod() {
        return financingMethod;
    }

    public void setFinancingMethod(String financingMethod) {
        this.financingMethod = financingMethod;
    }

    @NotNull(message = "最少天数不能为空")
    public Long getMinimumDay() {
        return minimumDay;
    }

    public void setMinimumDay(Long minimumDay) {
        this.minimumDay = minimumDay;
    }

    @JsonFormat(pattern = "yyyy-MM-dd")
//	@NotNull(message="还款日期不能为空")
    public Date getInvestorRepaymentDate() {
        return investorRepaymentDate;
    }

    public void setInvestorRepaymentDate(Date investorRepaymentDate) {
        this.investorRepaymentDate = investorRepaymentDate;
    }

    //	@NotNull(message="发生天数不能为空")
    public Long getInvestorDays() {
        return investorDays;
    }

    public void setInvestorDays(Long investorDays) {
        this.investorDays = investorDays;
    }

    //	@NotNull(message="利息合计不能为空")
    public Double getInvestorTotalInterest() {
        return investorTotalInterest;
    }

    public void setInvestorTotalInterest(Double investorTotalInterest) {
        this.investorTotalInterest = investorTotalInterest;
    }

    //	@NotNull(message="本息合计不能为空")
    public Double getInvestorTotalPrincipalInterest() {
        return investorTotalPrincipalInterest;
    }

    public void setInvestorTotalPrincipalInterest(Double investorTotalPrincipalInterest) {
        this.investorTotalPrincipalInterest = investorTotalPrincipalInterest;
    }

    @JsonFormat(pattern = "yyyy-MM-dd")
//	@NotNull(message="还款日期不能为空")
    public Date getCustomerRepaymentDate() {
        return customerRepaymentDate;
    }

    public void setCustomerRepaymentDate(Date customerRepaymentDate) {
        this.customerRepaymentDate = customerRepaymentDate;
    }

    //	@NotNull(message="发生天数不能为空")
    public Long getCustomerDays() {
        return customerDays;
    }

    public void setCustomerDays(Long customerDays) {
        this.customerDays = customerDays;
    }

    //	@NotNull(message="客户利息合计不能为空")
    public Double getCustomerTotalInterest() {
        return customerTotalInterest;
    }

    public void setCustomerTotalInterest(Double customerTotalInterest) {
        this.customerTotalInterest = customerTotalInterest;
    }

    //	@NotNull(message="客户本息合计不能为空")
    public Double getCustomerTotalPrincipalInterest() {
        return customerTotalPrincipalInterest;
    }

    public void setCustomerTotalPrincipalInterest(Double customerTotalPrincipalInterest) {
        this.customerTotalPrincipalInterest = customerTotalPrincipalInterest;
    }

    public Date getCreateDate_gte() {
        return sqlMap.getWhere().getValue("create_date", QueryType.GTE);
    }

    public void setCreateDate_gte(Date createDate) {
        sqlMap.getWhere().and("create_date", QueryType.GTE, createDate);
    }

    public Date getCreateDate_lte() {
        return sqlMap.getWhere().getValue("create_date", QueryType.LTE);
    }

    public void setCreateDate_lte(Date createDate) {
        sqlMap.getWhere().and("create_date", QueryType.LTE, createDate);
    }

    public Date getUpdateDate_gte() {
        return sqlMap.getWhere().getValue("update_date", QueryType.GTE);
    }

    public void setUpdateDate_gte(Date updateDate) {
        sqlMap.getWhere().and("update_date", QueryType.GTE, updateDate);
    }

    public Date getUpdateDate_lte() {
        return sqlMap.getWhere().getValue("update_date", QueryType.LTE);
    }

    public void setUpdateDate_lte(Date updateDate) {
        sqlMap.getWhere().and("update_date", QueryType.LTE, updateDate);
    }

    public List < TfinancingServiceOrderDetail > getTfinancingServiceOrderDetailList1() {
        return tfinancingServiceOrderDetailList1;
    }

    public void setTfinancingServiceOrderDetailList1(List < TfinancingServiceOrderDetail > tfinancingServiceOrderDetailList1) {
        this.tfinancingServiceOrderDetailList1 = tfinancingServiceOrderDetailList1;
    }

    public List < TfinancingServiceOrderDetail > getTfinancingServiceOrderDetailList2() {
        return tfinancingServiceOrderDetailList2;
    }

    public void setTfinancingServiceOrderDetailList2(List < TfinancingServiceOrderDetail > tfinancingServiceOrderDetailList2) {
        this.tfinancingServiceOrderDetailList2 = tfinancingServiceOrderDetailList2;
    }

    public Company getCompany() {
        return company;
    }

    public void setCompany(Company company) {
        this.company = company;
    }

    public Supplier getSupplier() {
        return supplier;
    }

    public void setSupplier(Supplier supplier) {
        this.supplier = supplier;
    }

    public Twarehouse getWarehouse() {
        return warehouse;
    }

    public void setWarehouse(Twarehouse warehouse) {
        this.warehouse = warehouse;
    }

    @JsonFormat(pattern = "yyyy-MM-dd")
    public Date getSupplierStartDate() {
        return supplierStartDate;
    }

    public void setSupplierStartDate(Date supplierStartDate) {
        this.supplierStartDate = supplierStartDate;
    }

    @JsonFormat(pattern = "yyyy-MM-dd")
    public Date getCustomerStartDate() {
        return customerStartDate;
    }

    public void setCustomerStartDate(Date customerStartDate) {
        this.customerStartDate = customerStartDate;
    }

    public String getGroupName() {
        return groupName;
    }

    public void setGroupName(String groupName) {
        this.groupName = groupName;
    }

    public String getRecordStatus() {
        return recordStatus;
    }

    public void setRecordStatus(String recordStatus) {
        this.recordStatus = recordStatus;
    }
}
